#include <bits/stdc++.h>

using namespace std;

const int MAXN = 4e5+10;

#define in read()

typedef struct{int v,nxt;}edge;

int f[MAXN][2],g[MAXN],n,a[MAXN],h[MAXN],cnt,siz[MAXN],son[MAXN],po[MAXN];
edge e[MAXN<<1];
bool can[MAXN];

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1) + (x<<3) + (ch ^ 48);
	return x*sgn;
}

void link(int x,int y){e[++cnt] = (edge){y,h[x]};h[x] = cnt;}

void dfs(int x,int p){
	siz[x] = 1;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v; if(y == p) continue;
		dfs(y,x);
		siz[x] += siz[y];
		if(siz[y] > siz[son[x]]) son[x] = y;
		int t;
		if(siz[y] <= n/2) t = siz[y];
		else t = f[y][0];
		if(t <= n/2){
			if(t > f[x][0]) f[x][1] = f[x][0],f[x][0] = t,po[x] = y;
			else if(t > f[x][1]) f[x][1] = t;
		}
	}
}

void dp(int x,int p){
	can[x] = 1;
	if(n-siz[x] > n/2 && n - siz[x] - g[x] > n/2) can[x] = 0;
	if(siz[son[x]] > n/2 && siz[son[x]] - f[son[x]][0] > n/2) can[x] = 0;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v; if(y == p) continue;
		int t = 0;
		if(n - siz[x] <= n/2) t = n-siz[x];
		else t = g[x];
		g[y] = t;
		if(po[x] == y && f[x][0] != f[x][1]) g[y] = max(g[y],f[x][1]);
		else g[y] = max(g[y],f[x][0]);
		dp(y,x);
	}
}

int main (){
	n = in;
	for(int i = 1;i < n;i++) {
		int x = in,y = in;
		link(x,y);link(y,x);
	}
	dfs(1,0);
	dp(1,0);
	for(int i = 1;i <= n;i++) printf("%d ",can[i]);
	return 0;
}
